import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/layout/index.vue'

// 使用完整路径确保组件正确加载
const routes = [
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: 'home',
        name: 'home', 
        component: () => import('@/views/home.vue'),
        meta: { requiresAuth: true, title: '首页' }
      },{
        path: 'result',
        name: 'result', 
        component: () => import('@/views/result.vue'),
        meta: { requiresAuth: true, title: '评估结果' }
      },{
        path: 'detail',
        name: 'detail', 
        component: () => import('@/views/detail.vue'),
        meta: { requiresAuth: true, title: '兵器工业集团先进民品产业体系评估' }
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login.vue')
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes,
})

export default router
